/**
 * 
 */
package cn.com.guage.guc.collection.safe;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

/**
 * @author yangdechao
 * ArrayList线程不安全演示
 * 多线程环境下，会抛出 java.util.ConcurrentModificationException 异常
 */
public class ArrayListUnsafeTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		 List<String> list = new ArrayList<>();

		    for (int i = 0; i < 30; i++) {
		        new Thread(() -> {
		            list.add(UUID.randomUUID().toString().substring(0, 8));
		            System.out.println(list);
		        }).start();
		    }

	}

}
